const fs = require("fs");
const url = require("url");
const path = require("path");
module.exports = {
	// 接收的参数：
	// pathUrl:静态资源目录
	static({pathUrl,res,req,next}){
		let {pathname} = url.parse(req.url);
		if(pathname === "/") pathname = "/weibo.html";
		const fileUrl = path.join(pathUrl,pathname);
		if(fs.existsSync(fileUrl) && fs.statSync(fileUrl).isFile()){
			fs.readFile(fileUrl,(err,result)=>{
				res.end(result);
			})
		}else next();
	}
}